#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <unordered_set>


using namespace std;

void test01() {
    map<char, int> _map = {{'a', 1},
                           {'b', '1'},
                           {'b', '2'}};
    _map['a'] = 3;
    for (const auto &pair: _map) {
        cout << pair.first << " " << pair.second << endl;
    }

    cout << "--------------------" << endl;
    multimap<char, int> _mmap = {{'a', 1},
                                 {'b', 1},
                                 {'a', 2}};
    _mmap.insert(make_pair('a', 3));
    for (const auto &_pair: _mmap) {
        cout << _pair.first << " " << _pair.second << endl;
    }

    cout << _map.count('a') << endl;
    cout << _map.count('*') << endl;

    cout << _mmap.count('a') << endl;
    cout << _mmap.count('*') << endl;

    auto it = _map.find('*');
    if (it != _map.end()) {
        cout << it->first << " " << it->second << endl;
    } else {
        cout << "未找到" << endl;
    }

}

// set 集合 去重的 ~~ multi_set 红黑树实现
// unordered_set hash表
void test02() {
    set<int> _set;
    set<int> _set2 = {1, 23, 45, 23, 1};
    set<int> _set3;
    _set3.insert(12);
    _set3.insert(14);
    _set3.insert(13);

    for (auto it = _set2.begin(); it != _set2.end(); ++it) {
        cout << *it << endl;
    }
    cout << "-----------------" << endl;
    unordered_set<int> _set4 = {1, 23, 45, 23, 1};  //去重 但不排序

    for (auto it = _set4.begin(); it != _set4.end(); ++it) {
        cout << *it << endl;
    }
}

void test03(){
    int arr[]={23,45,78,69,16};
    set<int> _set;
    for(int i=0;i<sizeof(arr)/sizeof(int);++i){
        _set.insert(arr[i]);
    }
    for(auto it=_set.rbegin();it!=_set.rend();++it){
        cout<<*it<<endl;
    }
    cout<<"---------------------------"<<endl;
    set<int> _set2(arr,arr+sizeof(arr)/sizeof(int));
    vector<int> arr2(_set2.rbegin(),_set2.rend());
    for(int i=0;i<arr2.size();++i){
        cout<<arr2.at(i)<<endl;
    }
}


int main() {
    test03();
    // test02();
    // test01();
    return 0;
}